/**
 * Created by CZ on 2017/4/6.
 */
module.exports = function ($scope,$rootScope,$interval,$state,RequestService,$localStorage,modelService,commonConfig) {
    $scope.User = $localStorage.get('cloud');
    //验证开发者是否已绑定厂商
    RequestService.Request(commonConfig.cloudApi+'cloud/company/checkUserCompanyExists?userId='+$scope.User.detail.id,'GET').then(function(response){
        console.log(response);
        if(response === 'true'){
            $scope.isCompleteCompany = true; //通过判断是否给用户进入编辑
        }else {
            $scope.isCompleteCompany = false;
        }
    },function(error){
        console.log(error);
    });

    $scope.PageShow = 0;
    $scope.GoComplete = function(){  //进入填写信息页面
        $scope.PageShow = 1;
    };
    $scope.submitDeveloperInfo = function(Developer){  //提交信息
        var data={
            "companyName" : Developer.CompanyName,
            "email" : Developer.email,
            "id" : 0,
            "linkman" : Developer.LinkMan,
            "orgFile" : Developer.OrgFile,
            "phone" : Developer.Phone,
            "status" : 0,
            "userId" : $localStorage.get('cloud').detail.id
        };
        RequestService.Request( commonConfig.cloudApi+'cloud/company','POST',data).then(function(resopnse){
            console.log(resopnse);
            if(resopnse.code == 100){
                modelService.openTipsModel(resopnse.message)
            }else {
                $scope.PageShow = 2;
            }
        },function(error){
            console.log(error);
        });

    }


};